package top.drinyeit.nongmao.model

import android.content.Intent
import android.view.View
import top.drinyeit.nongmao.activity.AppraiseActivity


/**
 * Created by YJY on 2018/1/13.
 */

data class OrderGoodsBean(var commodity_picture: String,
                          var commodity_description: String,
                          var commodity_price: Double,
                          var commodity_sum: Int,
                          var id: Int,
                          var commodity_name: String,
                          var store_id: Int,
                          var store_name: String,
                          var child_order_id: String,
                          var order_state: Int,
                          var express_price: Double,
                          var order_price: Double,
                          var commodity_total_sum: Int,
                          var appraise_state: Int,
                          var type: Int,
                          var position: Int) : Cloneable {

    //去评价
    fun goEvaluate(view:View) {
        var intent=Intent(view.context,AppraiseActivity::class.java)
        intent.putExtra("children_order_id",child_order_id)
        view.context.startActivity(intent)
    }

    fun getOrderState(): String {
        return when (order_state) {
            0 -> "待支付"
            1 -> "待配送"
            2 -> "待签收"
            3 -> "已完成"
            4 -> "关闭"
            else -> ""
        }
    }
    fun showEvaluateButton():Boolean{
        return order_state==3&&appraise_state==0
    }

    fun getNumberText(): String {
        return "共" + commodity_total_sum + "件商品 合计 "
    }

    fun getPriceDescribe(): String {
        return "¥$order_price (含配送费¥$express_price )"
    }

    @Throws(CloneNotSupportedException::class)
    public override fun clone(): Any {
        val orderGoodsBean: OrderGoodsBean?
        orderGoodsBean = super.clone() as OrderGoodsBean
        return orderGoodsBean
    }
}